home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 424_02 / ED-157 / get_position.c < prev    next >
C/C++ Source or Header  |  1993-09-10  |  1KB  |  48 lines

  1. /*
  2.  * Copyright (C) 1992 by Rush Record (rhr@clio.rice.edu)
  3.  * 
  4.  * This file is part of ED.
  5.  * 
  6.  * ED is free software; you can redistribute it and/or modify it under the terms
  7.  * of the GNU General Public License as published by the Free Software Foundation.
  8.  * 
  9.  * ED is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  10.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11.  * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  12.  * 
  13.  * You should have received a copy of the GNU General Public License along with ED
  14.  * (see the file COPYING).  If not, write to the Free Software Foundation, 675
  15.  * Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17. #include "opsys.h"
  18.  
  19. #include "rec.h"
  20. #include "window.h"
  21. #include "ed_dec.h"
  22.  
  23. /******************************************************************************\
  24. |Routine: get_position
  25. |Callby: command edit show_param
  26. |Purpose: Returns the record number and byte offset from the beginning of the
  27. |         file of the cursor location.
  28. |Arguments:
  29. |    record is the return record number.
  30. |    byte is the returned byte offset from beginning of file.
  31. \******************************************************************************/
  32. void get_position(record,byte)
  33. Int *record;
  34. Int *byte;
  35. {
  36.     register rec_ptr r;
  37.     Int bc,rc;
  38.  
  39.     for(r = BASE->next,rc = bc = 0;r != CURREC;r = r->next)
  40.     {
  41.         rc++;
  42.         bc += r->length + 1;
  43.     }
  44.     *record = ++rc;
  45.     *byte = ++bc + CURBYT;
  46. }
  47.  
  48.